home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / xlib / xcbitmap / test.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-15  |  1.3 KB  |  74 lines

  1. #include <conio.h>
  2. #include <stdlib.h>
  3.  
  4. #include "quicky.hpp"
  5. #include "xcbitmap.h"
  6. #include "xlib_all.h"
  7.  
  8. const ushort w=24;
  9. const ushort h=24;
  10. const ushort cbms=60;
  11.  
  12. char bitmap[w*h+2];
  13.  
  14. char cbm[1024*128];
  15.  
  16.  
  17. void main(void)
  18. {
  19.     x_set_mode(X_MODE_320x240,320);
  20.     x_set_doublebuffer(240);
  21.  
  22.     bitmap[0]=w;
  23.     bitmap[1]=h;
  24.     for( ushort a=0;a<h;a++ )
  25.     for( ushort b=0;b<w;b++ )
  26.         *(bitmap+2+(a*h)+b)=(a>h/3 && a<2*h/3 && b>w/3 && b<2*w/3)?0:a^b+16;
  27.  
  28.     ulong ul1, ul2;
  29.     ul1=x_sizeof_cbitmap(320/4,bitmap);
  30.     ul2=x_compile_bitmap(320/4,bitmap,cbm);
  31.     
  32.  
  33.     ushort x[cbms];
  34.     ushort y[cbms];
  35.     ushort vx[cbms];
  36.     ushort vy[cbms];
  37.  
  38.     for( ushort u=0;u<cbms;u++ )
  39.     {
  40.     x[u]=rand()%(ScrnPhysicalPixelWidth-w);
  41.     y[u]=rand()%(ScrnPhysicalHeight-h);
  42.     vx[u]=rand()%5 -2;
  43.     vy[u]=rand()%5 -2;
  44.     }
  45.  
  46.     
  47.     while( !kbhit() )
  48.     {
  49.     x_rect_fill(0,0,ScrnLogicalPixelWidth-1,ScrnLogicalHeight-1,HiddenPageOffs,0);
  50.     for( u=0;u<cbms;u++ )
  51.     {
  52.         x_put_cbitmap(x[u],y[u],HiddenPageOffs,cbm);
  53.         x[u]+=vx[u];
  54.         y[u]+=vy[u];
  55.         if( x[u]<0 || x[u]>=ScrnPhysicalPixelWidth-w )
  56.         {
  57.         vx[u]*=-1;
  58.         x[u]+=vx[u];
  59.         }
  60.         if( y[u]<0 || y[u]>=ScrnPhysicalHeight-h )
  61.         {
  62.         vy[u]*=-1;
  63.         y[u]+=vy[u];
  64.         }
  65.     }
  66.  
  67.     x_page_flip(0,0);
  68.     }
  69.         
  70.     getch();
  71.  
  72.     x_text_mode();
  73. }
  74.